package com.bobo.model;

/**
 * @author bobobo
 * @version 1.0
 * @date 2019/9/6 18:16
 */
public class SelectionSortData {
    private int[] numbers;

    public int orderedIndex = -1;   //[0 ... orderedIndex)有序
    public int currentMinIndex = -1;  //当前找到的最小元素的索引
    public int currentCompareIndex = -1; //当前正在比较的元素索引

    public SelectionSortData(int N,int randomBound){
        numbers = new int[N];

        for (int i = 0;i < N;i++)
            numbers[i] = (int) (Math.random()*randomBound) + 1;
    }

    public int N(){
        return numbers.length;
    }

    public int get(int index){
        if (index < 0 || index >= numbers.length)
            throw new IllegalArgumentException("索引越界");
        return numbers[index];
    }

    public void swap(int i,int j){
        int t = numbers[i];
        numbers[i] = numbers[j];
        numbers[j] = t;
    }
}
